﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.SessionState;

namespace System.Web.Mvc
{
    /// <summary>
    /// Session值提供程序
    /// </summary>
    internal sealed class SessionValueProvider : IValueProvider
    {
        public SessionValueProvider(HttpSessionStateBase session)
        {
            Session = session;
        }

        HttpSessionStateBase Session { get; set; }

        public bool ContainsPrefix(string prefix)
        {
            return Session[prefix] != null;
        }

        public ValueProviderResult GetValue(string key)
        {
            ValueProviderResult result = new ValueProviderResult(Session[key], null, Globalization.CultureInfo.CurrentCulture);
            return result;
        }
    }
}
